package com.horizon.im.imServer.protoBuilder;

import com.horizon.im.common.ProtocolInstant;
import com.horizon.im.common.bean.msg.ProtoMsg;
import org.springframework.stereotype.Service;

@Service("LoginResponseBuilder")
public class LoginResponseBuilder {
    //登录应答，应答消息
    public ProtoMsg.Message loginResponse(
            ProtocolInstant.ResultCodeEnum en,
            long seqId, String sessionId
    ){
        ProtoMsg.Message.Builder mb = ProtoMsg.Message.newBuilder().setType(
                ProtoMsg.HeadType.LOGIN_RESPONSE//设置消息类型
        ).setSequence(seqId).setSessionId(sessionId);//设置应答流水，与请求对应
        ProtoMsg.LoginResponse.Builder b = ProtoMsg.LoginResponse.newBuilder()
                .setCode(en.getCode()).setInfo(en.getDesc())
                .setExpose(1);
        mb.setLoginResponse(b.build());
        return mb.build();
    }
}
